A Bridge for Linking Two Publish/Subscribe Message Brokers

ABSTRACT

There is disclosed a method, computer program and bridge for linking two publish/subscribe message brokers together. A subscription is made to receive request messages on one or more topics from a first broker. A subscription is made to receive all messages published at either the first or the second broker to a replyto topic including a bridge identifier. A request message is received from the first broker, the request message specifying a temporary replyto topic on which responses to the request should be published. The temporary reply to topic is modified to specify a bridge identifier. The modified request message is forwarded to a second broker. A response to the request is received from the second broker, the response being published on the replyto topic including the bridge identifier. The bridge receives the response as a result of the subscription to receive all messages published to a topic including the bridge identifier. The response is forwarded to the first broker.

The invention relates to the field of publish/subscribe (pub/sub) andmore particularly to the bridging of two pub/sub message brokers inorder to create a single messaging domain.

BACKGROUND OF THE INVENTION

Publish/subscribe data processing systems have become very popular inrecent years as a way of distributing data messages. Publishers are notconcerned with where their publications are going, and subscribers arenot interested in where the messages they receive have come from.Instead, a message broker typically assures the integrity of the messagesource, and manages the distribution of the message according to thevalid subscriptions registered in the broker.

FIG. 1 illustrates a typical publish/subscribe data processing systemaccording to the prior art. A message broker 15 has an input mechanism20 which may be, for example, an input queue or a synchronous input nodeby which messages are input when they are sent by a publisher 5; 10 tothe message broker. A published message is fetched from the inputmechanism by a controller 40 and processed to determine, amongst otherthings, to which subscribers 60; 65; 70 the message should be sent.

Message topics typically provide the key to the delivery of messagesbetween publishers and subscribers. The broker attempts to match a topicstring on a published message with a list of clients who have subscribedto receive publications including that topic string. A matching engine30 is provided in the message broker for this very purpose. When thesubscriber registers, it must typically specify a means by which itwants to receive messages (which may be a queue or other inputmechanism) and a definition of the types of messages that it isinterested in. A subscriber can specify, for example, that it wishes toreceive messages including a topic string such as “employee/salary” andany messages matching that topic string will be identified and forwardedon to the subscriber via an output mechanism 50. (Note, there may bemore than one input and output mechanism to and from which messages arereceived and sent by the message broker.)

Publishers and subscribers may also interact with a homogeneous networkof brokers (in which each broker is a linked installation of the sameproduct), each one of which propagates subscriptions and forwardspublications to other brokers within the network. In this way thenetwork of brokers may act as a single broker.

A publish/subscribe system may however comprise two messaging brokers (Aand B) which may be installations of different products. With the helpof bridging technology, it is also possible to join the two brokerstogether using only the public publisher and subscriber APIs in order topresent a unified publish/subscribe messaging system in whichsubscribers attached to both brokers can receive publication messagesunaware of the broker to which the publisher was connected. This allowsthe heterogeneous brokers to be viewed as a single messaging domain,which is a key goal of application integration technologies.

Messages published to either of the brokers may also include a topic onwhich a reply message should be published in order to be processed bythe original publishing application. This is known as request/replymessaging. Like the topic on which the original message is published,the reply topic is defined in the original application, and so theadministrator can examine the application code to determine which topicis being used for replies, and configure an appropriate topic mapping inthe bridging application to enable the reply message to return to thecorrect side of the bridge to be processed by the requester.

It is not however possible to define this topic mapping if a temporarytopic is being used as the reply topic. Temporary topics are a facilitywhich may be provided by a messaging broker which dynamically generatesa unique topic name to be used by the requesting application.

Temporary topics are normally used as reply destinations in situationswhere the requesting application:

(i) Cannot rely on the existence of a pre-defined resource (e.g. topic)that could be used to receive the response (a reduced configurationoverhead).

(ii) Wishes to avoid other applications being able to receive the replymessage (better security).

(iii) Wishes to avoid having to filter the response message from othermessages published on the same topic (better efficiency).

The name of the temporary topic is not known until the point at which itis created, and the existence of the temporary topic lasts only untilthe requesting application is closed. Since the name of the temporarytopic is

not known in advance, it is not possible to predefine a topic mappingthat would enable the reply message to return to the requestingapplication. Thus a response will never be received. This prevents thetwo brokers from being viewed as a single messaging domain since thisbasic operation will only work correctly if the requesting andresponding applications are connected to the same broker.

SUMMARY OF THE INVENTION

According to a first aspect, there is provided a method for a bridgelinking two publish/subscribe message brokers together, the methodcomprising: subscribing to receive request messages on one or moretopics from a first broker; subscribing to receive all messagespublished at either the first or the second broker to a replyto topicincluding a bridge identifier; receiving a request message from thefirst broker, the request message specifying a temporary replyto topicon which responses to the request should be published; modifying thetemporary replyto topic to specify a bridge identifier; forwarding themodified request message to a second broker; receiving a response to therequest from the second broker, the response being published on thereplyto topic including the bridge identifier, the bridge receiving theresponse as a result of the subscription to receive all messagespublished to a topic including the bridge identifier; and forwarding theresponse on to the first broker.

Preferably the response message is modified to refer to the temporarytopic in its original unmodified form prior to forwarding the responseon to the first broker. This is not however essential since the firstbroker may contain rules enabling it to determine which topic toassociate the reply message with.

In a preferred embodiment a mapping table is consulted in order todetermine where to forward a message to. This can apply to both requestand response messages.

A subscription is made to receive all messages published at either thefirst or the second broker and including the bridge identifier. This ispreferably done at startup and only one subscription (e.g. a wildcardsubscription) needs to be created to cope with message replies. Thisavoids the need to create a subscription for every temporary topicencountered. This is advantageous because there is less of anadministration cost involved with subscription requests and deletion ofsuch subscriptions when they expire. The runtime cost of matching apublication against subscriptions etc. is also reduced.

According to a second aspect, there is provided a bridge for linking twopublish/subscribe message brokers together, the bridge comprising: meansfor subscribing to receive request messages on one or more topics from afirst broker; means for subscribing to receive all messages published ateither the first or the second broker to a replyto topic including abridge identifier; means for receiving a request message from the firstbroker, the request message specifying a temporary replyto topic onwhich responses to the request should be published; means for modifyingthe temporary replyto topic to specify a bridge identifier; means forforwarding the modified request message to a second broker; means forreceiving a response to the request from the second broker, the responsebeing published on the replyto topic including the bridge identifier,the bridge receiving the response as a result of a subscription toreceive all messages published to a topic including the bridgeidentifier; and means for forwarding the response on to the firstbroker.

According to a third aspect, there is provided a computer program for abridge linking two publish/subscribe message brokers together, thecomputer program comprising program code means adapted to perform, whenthe program is run on a computer, the method steps of: subscribing toreceive request messages on one or more topics from a first broker;subscribing to receive all messages published at either the first or thesecond broker to a replyto topic including a bridge identifier;receiving a request message from the first broker, the request messagespecifying a temporary replyto topic on which responses to the requestshould be published; modifying the temporary replyto topic to specify abridge identifier; forwarding the modified request message to a secondbroker; receiving a response to the request from the second broker, theresponse being published on the replyto topic including the bridgeidentifier, the bridge receiving the response as a result of thesubscription to receive all messages published to a topic including thebridge identifier; and forwarding the response on to the first broker.

BRIEF DESCRIPTION OF THE DRAWINGS

A preferred embodiment of the present invention will now be described,by way of example only, and with reference to the following drawings:

FIG. 1 illustrates a prior art publish subscribe system; and

FIGS. 2 and 3 show a system in which two heterogeneous message employingstatic replyto topics are bridged; and

FIGS. 4 a, 4 b, 4 c and 4 d illustrate the components and processing ofa preferred embodiment of the present invention.

DETAILED DESCRIPTION

As discussed in the background section, brokers in a publish/subscribemessaging system may be bridged together.

The linking of the two brokers may be achieved by the creation of abridging application (bridge) which reads a static list of topicdefinitions (mappings) defined by an administrator, makes theappropriate subscriptions and registers the necessary publishers. Suchsubscriptions and registrations enable messages to flow between the twobrokers in the direction(s) indicated by the administrator on the chosentopics. Forming part of each topic mapping is information specific tothe broker type on each end of the bridge. This information controls howsubscriptions are made, and where publications are sent. The set ofbridged topics is may be chosen by the administrator to be the minimalset of topics that are required to be available to subscribers attachedto both brokers. This enables the joining of the two brokers to becarried out without re-publishing unnecessary messages, which might leadto excessive network traffic or load on the hardware hosting thebrokers.

FIG. 2 exemplifies such a system. Requester 100 creates a requestmessage 160 requesting roofing building quotes. A static (i.e.predefined) “replyto” topic of “roofquotes” is predefined by theapplication and is specified as part of the request.

Requester 100 sends its request 160 to Broker A (i.e. publishes on abuilding/quotes/roof topic). Broker A contains two topic spaces 110 and120. A topic space defines a set of topics to which subscribers cansubscribe and to which publishers can publish. Although this is notshown in the figure, the requester will specify the appropriate topicspace containing the building/quotes/roof topic when publishing request160 to broker A.

A bridging application 150 joins Broker A to a second broker Broker B inorder to effectively create (from the point of view of publishers andsubscribers) a single broker. In order to achieve this, the bridgesubscribes to receive publications on certain topics and dependent uponthe origin of any messages received, forwards the messages on to theappropriate broker. Such subscriptions are registered with theappropriate broker.

A mapping table at the bridge (see FIG. 3) defines which topics aresubscribed to and where the bridge is to forward any messages publishedon those topics.

Thus, for example, the mapping table owned by bridge 150 specifies thetopic building/quotes/roof and that it is to forward messages in eitherdirection between the two brokers (dependent upon where a messageoriginates from). The table also specifies the topic spaces betweenwhich messages should be communicated.

It will be appreciated from FIG. 3 that messages may equally flow in onedirection only. For example, a request message relating to window quotesshould be received from Broker B only (topic space 130) and the bridgingapplication will forward this information onto Broker A (Topic Space120).

In the particular example, request message 160 is received by Broker Aand is forwarded onto bridge 150 as a result of the bridge'ssubscription to the building/quotes/roof topic. The bridge uses itsmapping table to determine that the request message should be forwardedonto Broker B (topic space 130).

A responder 120 has subscribed to receive roof quote requests andconsequently receives message 160. The request message contains anappropriate “replyto” to which the responder 120 publishes its responseat Broker B. The appropriate topic space for the replyto topic may bespecified in the request. Of course some brokers may not understand theconcept of a topic space. A broker may use another mechanism via whichmessages are received (e.g. a queue).

Again the bridge has subscribed to receive such reply publications andthe mapping table defines that the bridge should forward suchpublications to Broker A, topic space 110, for forwarding to requester100 (see FIG. 3).

It should thus be appreciated that the process works well when arequester specifies a static replyto topic which can be predefined (e.g.at setup by an administrator) in a bridge mapping table.

The situation becomes more problematic when temporary replyto topics areused. As discussed above temporary topics are dynamically created (uponrequest by a requesting application) and consequently the name of thetemporary topic is not known until the point at which it is created.

The present invention addresses the problem of temporary replyto topicsand a preferred embodiment of the present invention will be discussedwith reference to FIGS. 4 a, 4 b, 4 c and 4 d.

A requester 210 requests a temporary replyto topic from broker A (step300). Broker A assigns a replyto topic and it is received by therequester 210 at step 310. In this embodiment a new topic space iscreated for each assigned temporary topic (this is howeverimplementation specific.) Requester 210 then creates a request message260 at step 320. In addition to its payload (not shown), the requestmessage 260 indicates a request topic to which the request is to bepublished (building/quotes/roof) and a replyto topic to which repliesshould be addressed. By way of example, all temporary topics mightconsist of some way of identifying the string as a temporary topic (e.g.an _T prefix) and then the unique part of the temporary replyto topicwhich might be some form of UUID (e.g. a0cl2ffbbccaa6573567427). Thus atemporary topic may look as follows; _Ta0cl2ffbbccaa6573567427”.

The request is then published to the indicated request topic at Broker A(step 330). (Note, for each topic, an appropriate topic space may alsobe specified. This does of course depend upon whether the brokersupports the concept of a topic space.)

Bridge 250 links Broker A to Broker B. This is useful because responderand requester applications may attach to either broker.

The bridge subscribes on certain topics such as building/quotes/roof. Inother words, on all topics for which messages are to pass between thetwo brokers. As a result of the bridge's subscription onbuilding/quotes/roof, Broker A forwards request message 260 thereto(step 340).

Bridge 250 receives the request message and modifies the replyto fieldat step 350 such that it includes the following:

1) A constant identifier that identifies the modified replyto topic asbeing owned by the bridging application (e.g. _Bridge);

2) Routing information inserted by the bridging application thatcontains all the necessary information required to route any replymessages back to the original broker (e.g. topic space, queue etc.).This information is dependent upon the type of broker to which theresponse is being delivered In one implementation the publicationoriginates from the same topic space to which replies should beaddressed. In another embodiment, the requester may actually specify therouting information; and

3) The original temporary reply topic (e.g. _Ta0cl2ffbbccaa6573567427).

Thus the original temporary topic of _Ta0cl2ffbbccaa6573567427 nowbecomes _Bridge/_Ta0cl2ffbbccaa6573567427. Note, the _T denoting in thisexample that this is a temporary topic could be deleted rather thanreplaced by _Bridge. The bridge is configured to understand/is informedof the format of a temporary topic so that such temporary topics can bemodified as discussed above.

The request message is then forwarded on to Broker B (step 360) whoforwards this onto the responder (step 370).

Responder 220 extracts the replyto topic from the request message atstep 380. The responder creates a reply 270 to the request (step 390)and publishes the reply on the specified replyto topic to broker B (step400).

The bridge has subscribed with broker B to receive any messagespublished on a topic prefixed with _Bridge. Consequently broker Bforwards the reply to the bridge (step 410).

As indicated earlier, the bridge has a mapping table which indicates viaa set of static mappings how to flow messages between the two brokers(see FIG. 3). In addition the bridge dynamically creates a subscriptionfor all messages published to a topic including the bridge identifier_Bridge 266. The information on how to route the response message isencoded as part of the modified reply to topic. This subscription is inone embodiment, held separately from the static mapping table.

The dynamic subscription indicates that the bridge should forwardinformation including the identifier on to either of broker A or brokerB. If a message is received from broker B on topic space 240, it shouldbe forwarded to broker A, topic space 230. If a message is received frombroker A on topic space 220, it should be forwarded to broker B on topicspace 230 etc.

Before forwarding a message on however, the bridge modifies (at step420) the replyto topic back to its original form i.e._Ta0cl2ffbbccaa6573567427 based on some rules.

The replyto topic is modified because this is the form that the brokerwhich allocated the replyto topic understands.

Having modified the replyto topic, the bridge forwards the reply toBroker A (step 430) which then forwards the reply on to the Requester(step 440).

Thus, in summary the bridge application observes each temporary topic asit crosses the ‘bridge’, and modifies it to a form in which repliespublished on the modified topic can be automatically received by thebridging application and returned to the original broker withoutrequiring any stored state on a per-temporary-topic basis.

This approach solves the problem of being able to return reply messagesto the requesting application, while removing the responsibility fordefining a topic mapping from the administrator. This is importantbecause it is extremely difficult to define such topic mappings sincethey are assigned dynamically and are not known at setup time.Importantly it also produces a scenario in which there is a fixed (andinsignificant) cost to routing the reply messages independent of thenumber of temporary reply topics that are used by the applications. Thiscost is a single subscription capable of returning all temporary topicreply messages.

It should be appreciated that the brokers bridged by the bridgingapplication may be heterogeneous or homogenous.

Rather than subscribing to receive all messages simply including thebridge identifier (_bridge/*), a subscription could be made per topicspace—e.g. _bridge/topicspacel/*; _bridge/topicspace2/* etc. Thishowever requires storing more state information.

1. A method for a bridge linking two publish/subscribe message brokerstogether, the method comprising: subscribing to receive request messageson one or more topics from a first broker; subscribing to receive allmessages published at either the first or the second broker to a replytotopic including a bridge identifier; receiving a request message fromthe first broker, the request message specifying a temporary replytotopic on which responses to the request should be published; modifyingthe temporary replyto topic to specify a bridge identifier; forwardingthe modified request message to a second broker; receiving a response tothe request from the second broker, the response being published on thereplyto topic including the bridge identifier, the bridge receiving theresponse as a result of the subscription to receive all messagespublished to a topic including the bridge identifier; and forwarding theresponse on to the first broker.
 2. The method of claim 1, furthercomprising the step of: modifying the response message to refer to thetemporary topic in its original unmodified form prior to forwarding theresponse on to the first broker.
 3. The method of claim 1 or 2comprising: consulting a mapping table in order to determine where toforward a message to.
 4. A Bridge for linking two publish/subscribemessage brokers together, the bridge comprising: means for subscribingto receive request messages on one or more topics from a first broker;means for subscribing to receive all messages published at either thefirst or the second broker to a replyto topic including a bridgeidentifier; means for receiving a request message from the first broker,the request message specifying a temporary replyto topic on whichresponses to the request should be published; means for modifying thetemporary replyto topic to specify a bridge identifier; means forforwarding the modified request message to a second broker; means forreceiving a response to the request from the second broker, the responsebeing published on the replyto topic including the bridge identifier,the bridge receiving the response as a result of a subscription toreceive all messages published to a topic including the bridgeidentifier; and means for forwarding the response on to the firstbroker.
 5. The bridge of claim 4, further comprising: means formodifying the response message to refer to the temporary topic in itsoriginal unmodified form prior to forwarding the response on to thefirst broker.
 6. The bridge of claim 4 or 5 comprising: means forconsulting a mapping table in order to determine where to forward amessage to.
 7. A computer program for a bridge linking twopublish/subscribe message brokers together, the computer programcomprising program code means adapted to perform, when the program isrun on a computer, the method steps of: subscribing to receive requestmessages on one or more topics from a first broker; subscribing toreceive all messages published at either the first or the second brokerto a replyto topic including a bridge identifier; receiving a requestmessage from the first broker, the request message specifying atemporary replyto topic on which responses to the request should bepublished; modifying the temporary replyto topic to specify a bridgeidentifier; forwarding the modified request message to a second broker;receiving a response to the request from the second broker, the responsebeing published on the replyto topic including the bridge identifier,the bridge receiving the response as a result of the subscription toreceive all messages published to a topic including the bridgeidentifier; and forwarding the response on to the first broker.
 8. Thecomputer program of claim 7, wherein the program code means is furtheradapted to perform, when the program is run on a computer, the methodstep of: modifying the response message to refer to the temporary topicin its original unmodified form prior to forwarding the response on tothe first broker.
 9. The computer program of claim 7 or 8, wherein theprogram code means is further adapted to perform, when the program isrun on a computer, the method step of: consulting a mapping table inorder to determine where to forward a message to.